﻿using Codeflows;
using System.Threading.Tasks;
using System.Threading;
using Codeflows.Results;

namespace CodeflowsTests.Scenarios
{
    public class AsyncCodeflow : Codeflow
    {
        public Task<Result> Start()
        {
            return Task.Factory.StartNew(() =>
                {
                    Thread.Sleep(1000);
                    return Jump<AsyncCodeflow>(c => c.Step2());
                });
        }

        public Task<Result> Step2()
        {
            return Task.Factory.StartNew(() => Jump<AsyncCodeflow>(c => c.LastStep()));
        }

        public Result LastStep()
        {
            return End(10);
        }
    }
}
